package model.vo;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class OrderVO {
    private Integer id;
    private Integer userId;
    private Integer goodsDetailId;
    private String goods;
    private String spec;
    private Integer goodsNum;
    private Double amount;
    private Integer stateId;
    private String state;
    private U user = new U();

    public static final Map<String, String> MAPFROM;
    static {
        Map<String, String> map = new HashMap<>();
        map.put("user_id", "userId");
        map.put("spec_id", "goodsDetailId");
        map.put("number", "goodsNum");
        map.put("state", "stateId");
        map.put("recipient", "name");
        MAPFROM = Collections.unmodifiableMap(map);
    }

    public OrderVO() {}

    public OrderVO(Integer id, Integer userId, Integer goodsDetailId, String goods, String spec, Integer goodsNum, Double amount, Integer stateId, String state, U user) {
        this.id = id;
        this.userId = userId;
        this.goodsDetailId = goodsDetailId;
        this.goods = goods;
        this.spec = spec;
        this.goodsNum = goodsNum;
        this.amount = amount;
        this.stateId = stateId;
        this.state = state;
        this.user = user;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public Integer getGoodsDetailId() {
        return goodsDetailId;
    }

    public void setGoodsDetailId(Integer goodsDetailId) {
        this.goodsDetailId = goodsDetailId;
    }

    public String getGoods() {
        return goods;
    }

    public void setGoods(String goods) {
        this.goods = goods;
    }

    public String getSpec() {
        return spec;
    }

    public void setSpec(String spec) {
        this.spec = spec;
    }

    public Integer getGoodsNum() {
        return goodsNum;
    }

    public void setGoodsNum(Integer goodsNum) {
        this.goodsNum = goodsNum;
    }

    public Double getAmount() {
        return amount;
    }

    public void setAmount(Double amount) {
        this.amount = amount;
    }

    public Integer getStateId() {
        return stateId;
    }

    public void setStateId(Integer stateId) {
        this.stateId = stateId;
        switch (stateId) {
            case 0: state = "未付款"; break;
            case 1: state = "未发货"; break;
            case 2: state = "已发货"; break;
            case 3: state = "已到货"; break;
            default: break;
        }
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public U getUser() {
        return user;
    }

    public void setUser(U user) {
        this.user = user;
    }

    public String getNickname() {
        return user.getNickname();
    }

    public void setNickname(String nickname) {
        user.setNickname(nickname);
    }

    public String getName() {
        return user.getName();
    }

    public void setName(String name) {
        user.setName(name);
    }

    public String getAddress() {
        return user.getAddress();
    }

    public void setAddress(String address) {
        user.setAddress(address);
    }

    public String getPhone() {
        return user.getPhone();
    }

    public void setPhone(String phone) {
        user.setPhone(phone);
    }

    @Override
    public String toString() {
        return "OrderVO{" +
                "id=" + id +
                ", userId=" + userId +
                ", goodsDetailId=" + goodsDetailId +
                ", goods='" + goods + '\'' +
                ", spec='" + spec + '\'' +
                ", goodsNum=" + goodsNum +
                ", amount=" + amount +
                ", stateId=" + stateId +
                ", state='" + state + '\'' +
                ", user=" + user +
                '}';
    }

    public static class U {
        private String nickname;
        private String name;
        private String address;
        private String phone;

        public U() {}

        public U(String nickname, String name, String address, String phone) {
            this.nickname = nickname;
            this.name = name;
            this.address = address;
            this.phone = phone;
        }

        public String getNickname() {
            return nickname;
        }

        public void setNickname(String nickname) {
            this.nickname = nickname;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getAddress() {
            return address;
        }

        public void setAddress(String address) {
            this.address = address;
        }

        public String getPhone() {
            return phone;
        }

        public void setPhone(String phone) {
            this.phone = phone;
        }

        @Override
        public String toString() {
            return "U{" +
                    "nickname='" + nickname + '\'' +
                    ", name='" + name + '\'' +
                    ", address='" + address + '\'' +
                    ", phone='" + phone + '\'' +
                    '}';
        }
    }
}


//public class OrderVO {
//    private Integer id;
//    private String nickname;
//    private String name;
//    private String address;
//    private String phone;
//    private String goods;
//    private Integer goodsId;
//    private String spec;
//    private Integer goodsDetailId;
//    private Integer num;
//    private Double amount;
//    private Integer stateId;
//    private Timestamp createtime;
//    private Timestamp updatetime;
//    private Integer hasComment;
//
//    public static final Map<String, String> MAPTO;
//    static { //用于ModelUtils的CopyProperties，该映射关系与Order类绑定
//        Map<String, String> tmp = new HashMap<>();
//        tmp.put("name", "recipient");
//        tmp.put("goodsDetailId", "specId");
//        tmp.put("num", "number");
//        tmp.put("stateId", "state");
//        MAPTO = Collections.unmodifiableMap(tmp);
//    }
//
//    public OrderVO(){}
//
//    public OrderVO(Integer id, String nickname, String name, String address, String phone, String goods, Integer goodsId, String spec, Integer goodsDetailId, Integer num, Double amount, Integer stateId, Timestamp createtime, Timestamp updatetime, Integer hasComment) {
//        this.id = id;
//        this.nickname = nickname;
//        this.name = name;
//        this.address = address;
//        this.phone = phone;
//        this.goods = goods;
//        this.goodsId = goodsId;
//        this.spec = spec;
//        this.goodsDetailId = goodsDetailId;
//        this.num = num;
//        this.amount = amount;
//        this.stateId = stateId;
//        this.createtime = createtime;
//        this.updatetime = updatetime;
//        this.hasComment = hasComment;
//    }
//
//    public Integer getId() {
//        return id;
//    }
//
//    public void setId(Integer id) {
//        this.id = id;
//    }
//
//    public String getNickname() {
//        return nickname;
//    }
//
//    public void setNickname(String nickname) {
//        this.nickname = nickname;
//    }
//
//    public String getName() {
//        return name;
//    }
//
//    public void setName(String name) {
//        this.name = name;
//    }
//
//    public String getAddress() {
//        return address;
//    }
//
//    public void setAddress(String address) {
//        this.address = address;
//    }
//
//    public String getPhone() {
//        return phone;
//    }
//
//    public void setPhone(String phone) {
//        this.phone = phone;
//    }
//
//    public String getGoods() {
//        return goods;
//    }
//
//    public void setGoods(String goods) {
//        this.goods = goods;
//    }
//
//    public Integer getGoodsId() {
//        return goodsId;
//    }
//
//    public void setGoodsId(Integer goodsId) {
//        this.goodsId = goodsId;
//    }
//
//    public String getSpec() {
//        return spec;
//    }
//
//    public void setSpec(String spec) {
//        this.spec = spec;
//    }
//
//    public Integer getGoodsDetailId() {
//        return goodsDetailId;
//    }
//
//    public void setGoodsDetailId(Integer goodsDetailId) {
//        this.goodsDetailId = goodsDetailId;
//    }
//
//    public Integer getNum() {
//        return num;
//    }
//
//    public void setNum(Integer num) {
//        this.num = num;
//    }
//
//    public Double getAmount() {
//        return amount;
//    }
//
//    public void setAmount(Double amount) {
//        this.amount = amount;
//    }
//
//    public Integer getStateId() {
//        return stateId;
//    }
//
//    public void setStateId(Integer stateId) {
//        this.stateId = stateId;
//    }
//
//    public Timestamp getCreatetime() {
//        return createtime;
//    }
//
//    public void setCreatetime(Timestamp createtime) {
//        this.createtime = createtime;
//    }
//
//    public Timestamp getUpdatetime() {
//        return updatetime;
//    }
//
//    public void setUpdatetime(Timestamp updatetime) {
//        this.updatetime = updatetime;
//    }
//
//    public Integer getHasComment() {
//        return hasComment;
//    }
//
//    public void setHasComment(Integer hasComment) {
//        this.hasComment = hasComment;
//    }
//
//    @Override
//    public String toString() {
//        return "OrderBO{" +
//                "id=" + id +
//                ", nickname='" + nickname + '\'' +
//                ", name='" + name + '\'' +
//                ", address='" + address + '\'' +
//                ", phone='" + phone + '\'' +
//                ", goods='" + goods + '\'' +
//                ", goodsId=" + goodsId +
//                ", spec='" + spec + '\'' +
//                ", goodsDetailId=" + goodsDetailId +
//                ", num=" + num +
//                ", amount=" + amount +
//                ", stateId=" + stateId +
//                ", createtime=" + createtime +
//                ", updatetime=" + updatetime +
//                ", hasComment=" + hasComment +
//                '}';
//    }
//}
